#ifndef CMODULEPARENT_H
#define CMODULEPARENT_H

#include <iostream>
#include <list>
#include <vector>

class CTag;
class CModuleMgrParent;
typedef std::vector<std::string> VecStr;
typedef std::vector<CTag*> VecPTag;
typedef void (*LogCallback)(const char* message, int nLevel);

/***********************************************
* [className]   CModuleParent
* [func]        模块基类
* [author]      jhb
* [date]        2025-02-14
* [Modification Log]
* Version               By              Notes
* V0.0.1                jhb             初次创建
************************************************/
class CModuleParent
{
public:
    enum enumReturnType
    {
        enUnknown = -1,
        enOk,
        enError,
    };

public:
    virtual ~CModuleParent() {}
    //模块管理
    virtual void setModuleMgr(CModuleMgrParent *pMgr) = 0;
    //版本
    virtual std::string version() = 0;
    //设置配置
    virtual void setConfig(const std::string &sCfg) = 0;
    //配置(json格式，提供给web端使用)
    virtual std::string config() = 0;
    //启动
    virtual int start() = 0;
    //停止
    virtual void stop() = 0;
    //枚举测点
    virtual int enumTag(const std::string &addr, unsigned short *nCount) = 0;
    //检查格式
    virtual int checkFmt(const std::string &addr) = 0;
    //添加测点
    virtual int addTag(const std::string &addr, const int &nType, const unsigned int &cyc) = 0;
    //删除测点
    virtual int delTag(const std::string &addr) = 0;
    //清除测点
    virtual void clear() = 0;
    //读测点值
    virtual CTag* value(const std::string &addr) = 0;
    //批量读测点值
    virtual VecPTag values(const VecStr &vecAddr) = 0;
    //写测点值
    virtual int setValue(const std::string &addr, CTag *pTag) = 0;
    //写测点值
    virtual int setValue(const std::string &addr, CTag& Tag) = 0;
    //批量写测点值
    virtual int setValues(const VecStr &vecAddr, VecPTag vecTags) = 0;
    //写测点历史值
    virtual int setValueHistory(const std::string &addr, CTag *pTag) = 0;
    //写历史测点值
    virtual int setValueHistory(const std::string &addr, CTag& Tag) = 0;
    //批量写测点历史值
    virtual int setValuesHistory(const VecStr &vecAddr, VecPTag vecTags) = 0;
    //设置日志回调函数
    virtual void setLogRet(LogCallback callback) = 0;

protected:
    CModuleMgrParent        *m_pModuleMgr;      //模块管理指针
};

#endif //CMODULEPARENT_H
